/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年12月7日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.practice;

/**
 * @Type A20191207_builder_2
 * @Desc
 * @author 52489
 * @date 2019年12月7日
 * @Version V1.0
 */
public class A20191207_builder_2 {

    class Catcher {
        String catchModel;
        String config;
        String beginUrl;

        public String getCatchModel() {
            return catchModel;
        }

        public void setCatchModel(String catchModel) {
            this.catchModel = catchModel;
        }

        public String getConfig() {
            return config;
        }

        public void setConfig(String config) {
            this.config = config;
        }

        public String getBeginUrl() {
            return beginUrl;
        }

        public void setBeginUrl(String beginUrl) {
            this.beginUrl = beginUrl;
        }

    }

    interface CatcherBuilder {

        void buildCatchModel();

        void buildConfig();

        void buildBeginUrl();

        Catcher createCatcher();

    }

    class CatchAndPushModelBuilder implements CatcherBuilder {

        Catcher catcher = new Catcher();

        /*
         * (non-Javadoc)
         * 
         * @see
         * test.practice.A20191207_builder_2.CatcherBuilder#buildCatchModel()
         */
        @Override
        public void buildCatchModel() {
            catcher.setBeginUrl("beginurl");
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20191207_builder_2.CatcherBuilder#buildConfig()
         */
        @Override
        public void buildConfig() {
            catcher.setConfig("实时推送配置文件");
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20191207_builder_2.CatcherBuilder#buildBeginUrl()
         */
        @Override
        public void buildBeginUrl() {
            catcher.setCatchModel("实时推送模式");
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20191207_builder_2.CatcherBuilder#createCatcher()
         */
        @Override
        public Catcher createCatcher() {
            return catcher;
        }

    }

    interface Director {
        Catcher create();
    }

    class NewDirector implements Director {

        CatcherBuilder catcherBuilder;

        /**
         * @param catchAndPushModelBuilder
         */
        public NewDirector(CatcherBuilder catcherBuilder) {
            this.catcherBuilder = catcherBuilder;
        }

        public CatcherBuilder getCatcherBuilder() {
            return catcherBuilder;
        }

        /*
         * (non-Javadoc)
         * 
         * @see test.practice.A20191207_builder_2.Director#create()
         */
        @Override
        public Catcher create() {
            catcherBuilder.buildBeginUrl();
            catcherBuilder.buildCatchModel();
            catcherBuilder.buildConfig();
            return catcherBuilder.createCatcher();
        }

    }

    public static void main(String[] args) {
        A20191207_builder_2.Catcher catcher = new A20191207_builder_2().new NewDirector(
                new A20191207_builder_2().new CatchAndPushModelBuilder()).create();
        System.out.println(catcher.getCatchModel());
    }

}
